6 RBT_STATUS_MEM_EXHAUSTED
,
7 RBT_STATUS_DUPLICATE_KEY
,
8 RBT_STATUS_KEY_NOT_FOUND
11 typedef void *RbtIterator
;
12 typedef void *RbtHandle
;
14 RbtHandle
rbtNew(int(*compare
)(void *a
, void *b
));
15 // create red-black tree
17 // compare pointer to function that compares keys
19 // return < 0 if a < b
20 // return > 0 if a > b
22 // handle use handle in calls to rbt functions
25 void rbtDelete(RbtHandle h
);
26 // destroy red-black tree
28 RbtStatus
rbtInsert(RbtHandle h
, void *key
, void *value
);
29 // insert key/value pair
31 RbtStatus
rbtErase(RbtHandle h
, RbtIterator i
);
32 // delete node in tree associated with iterator
33 // this function does not free the key/value pointers
35 RbtIterator
rbtNext(RbtHandle h
, RbtIterator i
);
38 RbtIterator
rbtBegin(RbtHandle h
);
39 // return pointer to first node
41 RbtIterator
rbtEnd(RbtHandle h
);
42 // return pointer to one past last node
44 void rbtKeyValue(RbtHandle h
, RbtIterator i
, void **key
, void **value
);
45 // returns key/value pair associated with iterator
47 RbtIterator
rbtFind(RbtHandle h
, void *key
);
48 // returns iterator associated with key